package com.yundasys.lab02springbootstudy.stopwatch;

import org.springframework.util.StopWatch;

/**
 * @PACKAGE_NAME: com.yundasys.lab02springbootstudy.stopwatch
 * @NAME: StopWatchTest
 * @USER: jiangta
 * @DATE: 2021/12/14
 * @TIME: 7:20 下午
 * @PROJECT_NAME: springboot-labs
 */
public class StopWatchTest {

    public static void main(String[] args) throws InterruptedException {

        //定义一个计数器
        StopWatch stopWatch = new StopWatch("统一一组任务耗时");
        // 统计任务一耗时
        stopWatch.start("任务一");
        Thread.sleep(1000);
        stopWatch.stop();

        //统计任务二耗时
        stopWatch.start("任务二");
        Thread.sleep(2000);
        stopWatch.stop();

        System.out.println(stopWatch.prettyPrint());
        System.out.println(stopWatch.toString());

    }
}
